<table class="tbl-home" border="0" cellspacing="0" cellpadding="0">
	   <tr>
			<th>Stt</th>
			<th>Tên fanfage</th>
			<th>Like</th>
			<th>Xem app</th>
			<!--<th>Mời tham gia</th>-->
		</tr>
	<?php 
	$appid = $this->appid;
	$pagelistarr = $this->pageslist;
	
	//print_r($pagelistarr);
	
	$facebook = new Ishali_Facebook(); 
	$fb = $facebook->getFB();
							 
	foreach ($pagelistarr AS $k=>$page)
	{
		$id_fb_page = '/'.$page['id_fb_page'];
		$pages_fb =  $fb->api($id_fb_page);
		$cltr = 'cl1';
		if($k % 2 == 0)
		{
			$cltr = 'cl2';
		}
	?>
    <tr>
		<td><?php echo $k+1; ?></td>
		<td><a href='javascript:void(0)'  onClick="window.open('<?php echo $pages_fb['link'] ?>')" ><?php echo $pages_fb['name']; ?></a></td>
		
<?php if(array_key_exists('likes', $pages_fb)) { ?>
		<td><a href='javascript:void(0)'  onClick="window.open('<?php echo $pages_fb['link']."?sk=likes" ?>')" ><?php echo $pages_fb['likes']; ?></a></td>
<?php } else { ?>
		<td><a href='javascript:void(0)'  onClick="window.open('<?php echo $pages_fb['link']."?sk=likes" ?>')" ><?php echo '0' ?></a></td>
<?php } ?>
		<td>
            <?php 
	        if(@$pages_fb['has_added_app']==1)
	        {
	        ?>
	        	 <a href='javascript:void(0)'  onClick="window.open('<?php echo $pages_fb['link']."?sk=app_".$appid ?>')" >Xem ứng dụng</a>
	        <?php 
	        }else 
	        {
	        ?>
	        	<a href='javascript:void(0)'  onClick="has_added_app(<?php echo $page['id_fb_page'] ?>,'to chuc cuoc thi',<?php echo $this->fbuserid ?>, <?php echo $appid ?>, 0)" >Cài ứng dụng</a>
	        <?php
	        }
	        ?>
        </td>
        <!--
		<td>
            <div id="fb-root"></div>
            <a href='#' onclick="FacebookInviteFriendsadmin('<?php echo $pages_fb['link']."?sk=app_".$appid ?>');">Mời tham gia</a>
        </td>
        -->
	</tr>

	<?php 
	}
    if(count($pagelistarr)<=0)
	{
		?>
		<tr height="35px" class="cl1">
			<td colspan="5">
				Chưa có trang nào, Chọn trang ở góc phải trên
			</td>
		</tr>
	<?php 
	}
	?>
</table>

	
	 <script src="http://connect.facebook.net/en_US/all.js"></script>
	<script type="text/javascript">
	  
			FB.init({
			appId:'<?php echo APP_ID ?>',
			cookie:true,
			status:true,
			xfbml:true
			});

			function FacebookInviteFriendsadmin(data)
			{
				
			FB.ui({
			method: 'apprequests',
			data: data,
			message: 'Your Message diaolog'
			});
			
			}
		</script>